// pages/djt/video/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tab: true,

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    this.setData({
      id: options.id || 4
    })
    if (wx.getSystemInfoSync().model.substr(0, 8) == "iPhone X") {
      this.setData({
        _top: true
      })
      this.videoContext = wx.createVideoContext('myVideo')
    }
    this.list()
  },

  bindtimeupdate: function (e) {
    this.setData({
      time: e.detail.currentTime
    })
  },

  list: function () {
    var _this = this;
    wx.ajax('/article/details/' + this.data.id,{one:22222}).then(res => {
      _this.setData({
        list: res.data,
        is_likes: res.data.is_likes,
        is_follow: res.data.is_follow,

      })
    })
  },
  // 点赞
  likes: function () {
    wx.ajax('/article/likes/' + this.data.id,{},'get',true).then(res => {
      this.setData({
        is_likes: !this.data.is_likes
      })
      wx.showToast({
        title: res.message,
        icon: "none"
      })

    })
  },
  // 收藏
  shoucahng: function () {
    wx.ajax('/article/follow/' + this.data.id,{},'get',true).then(res => {
      this.setData({
        is_follow: !this.data.is_follow
      })
      wx.showToast({
        title: res.message,
        icon: "none"
      })
    })
  },
  //  评论
  yes: function () {
    if (this.data.text && this.data.text != '') {
      var _data = {
        id: this.data.id,
        text: this.data.text,
        time: this.data.time,
      }


      wx.ajax('/article/comment',_data,'post',true).then(res=>{
        this.list()
        this.setData({
          tab:false,
          text:''
        })
        
      })
    }
  },
  vu: function (e) {
    this.setData({
      text: e.detail.value
    })
  },
  show: function () {
    this.setData({
      tab: true
    })
  },
  hide: function () {
    this.setData({
      tab: false
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})